package cn._2dland.uploader;

import java.io.IOException;
import java.io.OutputStream;

import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.params.HttpMethodParams;

public class CountingMultipartRequestEntity extends MultipartRequestEntity {
	private long total;
	private IProgressHandler handler;

	public CountingMultipartRequestEntity(Part[] parts, HttpMethodParams params, long fileLength, IProgressHandler handler) {
		super(parts, params);
		this.total = fileLength;
		this.handler = handler;
	}

	public void writeRequest(OutputStream out) throws IOException {
		super.writeRequest(new CountingOutputStream(out, total, handler));
	}
}
